﻿<%@ Control Language="C#" Inherits="Yuanlin.Business.ChangePassword, Yuanlin.Business"
    AutoEventWireup="true" %>

<script type="text/javascript">
    addEvent(window, 'load', onLoad);
    
    function onLoad()
    {
        if ("<%= CurrentUser.IsAdministrator%>".toLowerCase() == "false")
        {
            return;
        }
        var question1 = document.getElementById("question1");
        var answer1 = document.getElementById("answer1");
        var question2 = document.getElementById("question2");
        var answer2 = document.getElementById("answer2");
        var userId = document.getElementById("userId");
        question1.style.display = "none";
        answer1.style.display = "none";
        question2.style.display = "none";
        answer2.style.display = "none";
        userId.style.display = "none";
    }
    function checkPass()
    {
        var oldPassword = document.getElementById("<%=oldPasswordTextBox.ClientID %>").value;
        oldPassword = oldPassword.replace(/(^\s*)|(\s*$)/g,"");
        if(oldPassword.length<6 || oldPassword.length>12)
        {
            alert(" 密码6-12位");
            document.getElementById("<%=oldPasswordTextBox.ClientID %>").focus();
            return false;
        }
        
        var pwd1=document.all("<%=newPasswordTextBox.ClientID %>").value;
        pwd1=pwd1.replace(/(^\s*)|(\s*$)/g,"");

        if(pwd1.length<6 || pwd1.length>12){
            alert(" 密码6-12位");
            document.all("<%=newPasswordTextBox.ClientID %>").focus();
            return false;
        }
        var pwd2=document.all("<%=newPasswordConfirmTextBox.ClientID %>").value;
        pwd2=pwd2.replace(/(^\s*)|(\s*$)/g,"");
        if(pwd1!=pwd2){
            alert("密码两次输入的不一致,请重新输入!");
            document.all("<%=newPasswordConfirmTextBox.ClientID %>").focus();
            return false;
        }
        
        if ("<%= CurrentUser.IsAdministrator%>".toLowerCase() == "false")
        {
            var question1=document.all("<%=question1AnswerValuedTextBox.ClientID %>").value;
            var question2=document.all("<%=question2AnswerValuedTextBox.ClientID %>").value;
            var passwordProtectionNumber=document.all("<%=passwordProtectionNumberValuedTextBox.ClientID %>").value;
            if(question1.Trim().length > 0)
            {
                if(question2.Trim().length==0)
                {
                     alert("请填写答案或绿商ID！");
                     return false;
                }
            }
            if(question2.Trim().length > 0)
            {
                if(question1.Trim().length==0)
                {
                     alert("请填写答案或绿商ID！");
                     return false;
                }
            }
            if(passwordProtectionNumber.Trim().length==0 && question1.Trim().length==0 && question2.Trim().length==0)
            {
                alert("请填写答案或绿商ID！");
                return false;
            }
        }
        return true;
    }
</script>

<div class="AdminArea">
    <fieldset>
        <legend>
            <nwap:ResourceLiteral runat="server" ResourceName="ChangePassword_Title" ResourceFile="ControlPanelResources.xml" />
        </legend>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_OldPassword" />
            <nwap:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="oldPasswordTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_NewPassword" />
            <nwap:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="newPasswordTextBox" />
        </div>
        <div class="FormRow">
            <nwap:ResourceLabel CssClass="LargerFieldName" runat="Server" ResourceFile="ControlPanelResources.xml"
                ResourceName="ChangePassword_NewPasswordConfirm" />
            <nwap:ValuedTextBox runat="server" TextMode="Password" MaxLength="15" CssClass="InputField SmallWidth"
                ID="newPasswordConfirmTextBox" />
        </div>
        <div class="FormRow" id="question1">
            <nwap:ResourceLabel runat="Server" CssClass="FieldName" ResourceFile="ControlPanelResources.xml"
                ResourceName="RegisterUser_Question1" />
            <nwap:ValuedDropDownList runat="server" CssClass="InputField SmallWidth" ID="question1ValuedDropDownList" />
        </div>
        <div class="FormRow" id="answer1">
            <nwap:ResourceLabel runat="Server" CssClass="FieldName" ResourceFile="ControlPanelResources.xml"
                ResourceName="RegisterUser_Question1Answer" />
            <nwap:ValuedTextBox runat="server" CssClass="InputField SmallWidth" ID="question1AnswerValuedTextBox" />
        </div>
        <div class="FormRow" id="question2">
            <nwap:ResourceLabel runat="Server" CssClass="FieldName" ResourceFile="ControlPanelResources.xml"
                ResourceName="RegisterUser_Question2" />
            <nwap:ValuedDropDownList runat="server" CssClass="InputField SmallWidth" ID="question2ValuedDropDownList" />
        </div>
        <div class="FormRow" id="answer2">
            <nwap:ResourceLabel runat="Server" CssClass="FieldName" ResourceFile="ControlPanelResources.xml"
                ResourceName="RegisterUser_Question1Answer" />
            <nwap:ValuedTextBox runat="server" CssClass="InputField SmallWidth" ID="question2AnswerValuedTextBox" />
        </div>
        <div class="FormRow" id="userId">
            <nwap:ResourceLabel runat="Server" CssClass="FieldName" ResourceFile="ControlPanelResources.xml"
                ResourceName="RegisterUser_GreenNumber" />
            <nwap:ValuedTextBox runat="server" CssClass="InputField SmallWidth" ID="passwordProtectionNumberValuedTextBox" />
            <nwap:ResourceLabel runat="Server" ResourceFile="ControlPanelResources.xml" ResourceName="ChangePassword_UserIdDescription" />
        </div>
        <div class="FormRow SubmitButtonRow">
            <div class="FormRow MiddleWidth">
                <nwap:ResourceButton OnClientClick="return checkPass();" ID="saveButton" ResourceName="Save"
                    CssClass="Button" runat="server"></nwap:ResourceButton>
            </div>
        </div>
    </fieldset>
</div>
